﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BBPA.Admin.Store.Group_Buy
{
    public partial class history_form : FormPage
    {
        BLL.GroupBuy bll = new BLL.GroupBuy();
        BLL.Orders bllorder = new BLL.Orders();
        Model.GroupBuy gbmodel = new Model.GroupBuy();
        Model.Orders omodel = new Model.Orders();
        protected EnumHelper.UserType userType;
        protected bool isAdmin;
        Model.Store CurrentStore = new Model.Store();
        protected void Page_Load(object sender, EventArgs e)
        {
            userType = Security.GetCurrentUserType();
            isAdmin = userType == EnumHelper.UserType.Administrator;
            CurrentStore = Security.GetCurrentStore();

            //type = Request["type"] == null || Request["type"].ToString() == "" ? "" : Request["type"].ToString();
            //if (type == "history")
            //{
            //    btnSub.Visible = false;
            //}

        }

        /// <summary>
        /// 初始化本页Model
        /// </summary>
        public override void Page_Load_DefaultModel() { omodel = bllorder.GetModel(Master.id); gbmodel = bll.GetModel(omodel.Gbid); }

        /// <summary>
        /// 初始化表单
        /// </summary>
        public override void Form_Default()
        {
            Master.HideSubmit();
        }

        /// <summary>
        /// 绑定表单数据【修改时用】
        /// </summary>
        public override void Form_Bind()
        {

            lbltitle.Text = gbmodel.gbname;

            lblprice.Text = StringPlus.showCoin(gbmodel.gbprice);
            lblorderprice.Text = StringPlus.showCoin(gbmodel.gborderprice);
            lblpayprice.Text = StringPlus.showCoin(gbmodel.gbpayprice);
            lblendtime.Text = gbmodel.gbendtime.AddDays(-2).ToString("yyyy-MM-dd");
            lblendpaytime.Text = gbmodel.gbendtime.ToString("yyyy-MM-dd");

            lblcontet.Text = gbmodel.gbcontent;
            rp_Goods_Bing();
        }

        void rp_Goods_Bing()
        {
            BBPA.BLL.Group_Good gg_bll = new BLL.Group_Good();
            DataTable dt = gg_bll.GetList(" gg_gbid=" + omodel.Gbid + " and StoreID=" + CurrentStore.id + " and Ordersid=" + omodel.id).Tables[0];

            this.rp_Goods.DataSource = dt;
            this.rp_Goods.DataBind();
            Master.ScriptManager_js("Event_Amount_change();");
        }
    }
}